package com.lxl.testHd.mypartition;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author ：e_lixilin
 * @date ：2022/2/22 8:00
 * @description：
 * @modified By：
 */
public class AvgCarInfo implements Writable {
    public AvgCarInfo() {
        super();
    }

    public AvgCarInfo(long distance, long minutes, double speed) {
        this.distance = distance;
        this.minutes = minutes;
        this.speed = speed;
    }

    // 行驶公里数
    private long distance;
    // 行驶时间
    private long minutes;
    // 行驶速度
    private double speed;

    public AvgCarInfo(long distance, long betweenMinutes) {
        this.distance = distance;
        this.minutes = betweenMinutes;
    }

    /**
     * 序列化方法
     * @param out <code>DataOuput</code> to serialize this object into.
     * @throws IOException
     */
    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(distance);
        out.writeLong(minutes);
        out.writeDouble(speed);
    }

    /**
     * 反序列化方法
     * @param in <code>DataInput</code> to deseriablize this object from.
     * @throws IOException
     */
    @Override
    public void readFields(DataInput in) throws IOException {
    distance = in.readLong();
        minutes = in.readLong();
        speed = in.readDouble();
    }

    public long getDistance() {
        return distance;
    }

    public void setDistance(long distance) {
        this.distance = distance;
    }

    public long getMinutes() {
        return minutes;
    }

    public void setMinutes(long minutes) {
        this.minutes = minutes;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }
    @Override
    public String toString() {
        return distance + "\t" + minutes + "\t" + speed;
    }
}
